home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / vol_200 / 272_01 / getft.doc < prev    next >
Text File  |  1987-07-15  |  2KB  |  54 lines

  1.  
  2.  
  3.         NAME
  4.                 get_filetime -- get file date/time stamp
  5.  
  6.         SYNOPSIS
  7.                 #include <time.h>
  8.                 void get_filetime(ptm, fh);
  9.                 struct tm *ptm;     pointer to tm structure
  10.                 int fh;             file handle of opened file
  11.  
  12.  
  13.         DESCRIPTION
  14.         Datalight gives a function to set the date/time of a file,
  15.         but none to fetch it!.  This function corrects that omission.
  16.         The data from the file is placed in the specified time
  17.         structure (see Datalight "time.h"), in the same format as used
  18.         by other time functions by Datalight.  The file must be opened,
  19.         and a file handle passed, NOT a FILE pointer.  No error is
  20.         returned from this function.  The structure elements tm_wday
  21.         and tm_yday are always returned as 1, as they are generally
  22.         irrelevant for file dates.  They can subsequently be calculated
  23.         from the other information.
  24.  
  25.  
  26.  
  27.         EXAMPLE
  28.            #include <time.h>
  29.            #include <smdefs.h>
  30.            FILE *fp;
  31.            char *string;
  32.            struct tm *stamp;
  33.  
  34.            /* report the date/time of a specified file on command line */
  35.            main(argc, argv) int argc; char *argv[]; {
  36.               if(argc isnot 2) exit(0);
  37.               if((fd = fopen(argv[1], "r")) is NULL) exit(0);
  38.                      /* note conversion of FILE *fd to file handle next: */
  39.               get_filetime(stamp, (fileno(fd)));
  40.               fclose(fd);
  41.               string = asctime(stamp);
  42.               printf("File %s modified on %s\n", argv[1], string);
  43.               }
  44.  
  45.  
  46.  
  47.  
  48.  
  49.  
  50.  
  51.  
  52.  
  53.         This function is found in SMDLx.LIB for the Datalight Compiler.
  54.